package com.jindy.module.transferMachine.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.transferMachine.domain.SyTransferMachineT;
import com.jindy.module.transferMachine.service.ISyTransferMachineTService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 库存调拨机器记录Controller
 * 
 * @author jindy
 * @date 2023-04-13
 */
@RestController
@RequestMapping("/module/transferMachine")
public class SyTransferMachineTController extends BaseController
{
    @Resource
    private ISyTransferMachineTService syTransferMachineTService;

    /**
     * 查询库存调拨机器记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:list')")
    @GetMapping("/list")
    public TableDataInfo list(SyTransferMachineT syTransferMachineT)
    {
        startPage();
        List<SyTransferMachineT> list = syTransferMachineTService.selectSyTransferMachineTList(syTransferMachineT);
        return getDataTable(list);
    }

    /**
     * 导出库存调拨机器记录列表
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:export')")
    @Log(title = "库存调拨机器记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SyTransferMachineT syTransferMachineT)
    {
        List<SyTransferMachineT> list = syTransferMachineTService.selectSyTransferMachineTList(syTransferMachineT);
        ExcelUtil<SyTransferMachineT> util = new ExcelUtil<SyTransferMachineT>(SyTransferMachineT.class);
        util.exportExcel(response, list, "库存调拨机器记录数据");
    }

    /**
     * 获取库存调拨机器记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(syTransferMachineTService.selectSyTransferMachineTById(id));
    }

    /**
     * 新增库存调拨机器记录
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:add')")
    @Log(title = "库存调拨机器记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SyTransferMachineT syTransferMachineT)
    {
        return toAjax(syTransferMachineTService.insertSyTransferMachineT(syTransferMachineT));
    }

    /**
     * 扫码新增调拨机器出库，入库记录
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:add2')")
    @Log(title = "库存调拨机器记录", businessType = BusinessType.INSERT)
    @PostMapping("/post/add2")
    public AjaxResult add2(@RequestBody SyTransferMachineT syTransferMachineT)
    {
        return toAjax(syTransferMachineTService.insertSyTransferMachine(syTransferMachineT));
    }

    /**
     * 修改库存调拨机器记录
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:edit')")
    @Log(title = "库存调拨机器记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SyTransferMachineT syTransferMachineT)
    {
        return toAjax(syTransferMachineTService.updateSyTransferMachineT(syTransferMachineT));
    }

    /**
     * 删除库存调拨机器记录
     */
    @PreAuthorize("@ss.hasPermi('module:transferMachine:remove')")
    @Log(title = "库存调拨机器记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(syTransferMachineTService.deleteSyTransferMachineTByIds(ids));
    }
}
